const app = getApp();
import Paging from '../../../wxjs/Paging.js'
import navToNext from '../../../wxjs/navToNext.js'

var pag = new Paging();

var data = {
  xhx_images: app.xhx_images,
  xhx_route: app.xhx_route,
  userId:null,
  
  curNav: 0,
  dialogValue:null,
};

var currentPage = {
  data,
  listParams:{},
  reqUrl: app.serAddrs.getMyCoupon,
 
  onLoad,
  navTap,
  exchange,
  loadInit,
};

var page = Object.assign({}, navToNext, pag.func(), currentPage);

Page(page)



function onLoad(options) {
  // console.log('1111111111111',options)
  const that = this;

  var myInfo = app.isNavigateToLogin();
  if (!myInfo) return;
  myInfo = app.isNavigateToBind();
  if (!myInfo) return;

  that.navTap();
}
function loadInit() {
  const that = this;
  // 初始化
  that.navTap();
}

function exchange(){
  const that = this;
  var dialogValue = {
    dialogShow: true,
    dialogType: 2,  //领红包弹框
    title: '兑换成功',
    bgImage: that.data.xhx_images.exchangeBg,
    bgWidth: '700rpx',
    bgHeight: '820rpx',
    btnImage: that.data.xhx_images.exchangeBtn,
    btnWidth: '320rpx',
    btnHeight: '96rpx',

    couponsList:[
      { title:'首单立减', amount: '20', validay: '2019-07-10' },
      { title:'首单立减', amount: '20', validay: '2019-07-10' },
      { amount: '20',validay: '2019-07-10'},
    ],

    apply: '仅适用于智能团课',
    check:'在我的优惠券中查看',
    confirm: function () {

    },
    cancel: function () {

    }
  }

  that.setData({
    dialogValue: dialogValue
  });
}
function navTap(event) {
  // console.log('1111111111111111111',event);
  const that = this;
  var status=null;
  if(event){
    that.setData({
      curNav: event.target.dataset.id,
      lists:[]
    });
    status = event.target.dataset.id;
  }else{
    status=0;
  }
  
  that.listParams.couponUserId = app.userInfo.userId;
  that.listParams.status = status;
 
  that.pageListInit();
}